package com.ljkj.cordial.chat.dao.notify;

import android.text.TextUtils;

import com.lanjiu.lib.imclient.ims.IMSUtils;
import com.ljkj.cordial.chat.base.ChatApp;
import com.ljkj.cordial.chat.bean.Canstants;
import com.ljkj.cordial.chat.dao.ChatContentTableDao;
import com.ljkj.cordial.chat.dao.ChatTableBean;
import com.ljkj.cordial.chat.dao.DbController;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.Transient;

import java.util.ArrayList;
import java.util.List;

@Entity(nameInDb = "ChatContentTable")
public class ChatContentTable implements Comparable<ChatContentTable> {
    public final static int CHAT_SINGLE = 1;
    public final static int CHAT_GROUP = 2;
    public final static String TYPE_REGISTER = "1";
    public final static String TYPE_VISITOR = "2";
    /**
     * 进入chat的目标id，为空证明不在聊天页面
     */
    public static String inChatTargetId;
    @Id(autoincrement = true)
    private Long id;
    // 群成员ID
    @Property(nameInDb = "CHAT_TYPE")
    private int chatType;

    //    @Unique
    @Property(nameInDb = "TARGET_ID")
    private String targetId;
    /**
     * 1注册用户2游客
     */
    @Property(nameInDb = "TARGET_TYPE")
    private String targetType;
    @Property(nameInDb = "TARGET_NAME")
    private String targetName;
    @Property(nameInDb = "ALIAS")
    private String alias;
    @Property(nameInDb = "AVATAR_ID")
    private String avatarId;
    @Property(nameInDb = "TARGET_AVATAR_URL")
    private String targetAvatarUrl;
    @Property(nameInDb = "TARGET_AVATAR_PATH")
    private String targetAvatarPath;
    @Property(nameInDb = "TARGET_MEMBER_ID")
    private String targetMemberUserId;
    @Property(nameInDb = "MSG_NUM")
    private int msgNum;
    @Property(nameInDb = "LOGIN_USER_ID")
    private String loginUserId;
    @Property(nameInDb = "UPDATE_TIME")
    private long updateTime;
    @Property(nameInDb = "LAST_MSG")
    private String lastMsg;
    @Property(nameInDb = "LAST_MSG_TYPE")
    private int lastMsgType;
    @Property(nameInDb = "IS_SNAPCHAT")
    private int isSnapchat;
    @Property(nameInDb = "IS_READ")
    private int isRead;//0未读1已读
    /**
     * 0默认1置顶
     */
    @Property(nameInDb = "IS_TOP")
    private int isTOP;
    @Property(nameInDb = "TOP_UPDATE_TIME")//置顶时间
    private long updateTopTime;
    @Property(nameInDb = "ATEL_IDS")
    private String atelIds;
    @Transient
    private int receiveFrom;//区分消息来源UserChatTable.RECEIVE_FROM_ACTIVITY,UserChatTable.RECEIVE_FROM_NET
//    @Convert(columnType = String.class, converter = MemberConverter.class)
//    private List<GroupMemberTable> memberList;


    @Generated(hash = 976846517)
    public ChatContentTable(Long id, int chatType, String targetId, String targetType, String targetName, String alias, String avatarId, String targetAvatarUrl, String targetAvatarPath, String targetMemberUserId, int msgNum,
                            String loginUserId, long updateTime, String lastMsg, int lastMsgType, int isSnapchat, int isRead, int isTOP, long updateTopTime, String atelIds) {
        this.id = id;
        this.chatType = chatType;
        this.targetId = targetId;
        this.targetType = targetType;
        this.targetName = targetName;
        this.alias = alias;
        this.avatarId = avatarId;
        this.targetAvatarUrl = targetAvatarUrl;
        this.targetAvatarPath = targetAvatarPath;
        this.targetMemberUserId = targetMemberUserId;
        this.msgNum = msgNum;
        this.loginUserId = loginUserId;
        this.updateTime = updateTime;
        this.lastMsg = lastMsg;
        this.lastMsgType = lastMsgType;
        this.isSnapchat = isSnapchat;
        this.isRead = isRead;
        this.isTOP = isTOP;
        this.updateTopTime = updateTopTime;
        this.atelIds = atelIds;
    }

    @Generated(hash = 1982586302)
    public ChatContentTable() {
    }


    public static void insert(ChatContentTable contentTable) {
        contentTable.setUpdateTime(System.currentTimeMillis());
        if (contentTable.getId() != null) {
            contentTable.setMsgNum(contentTable.getMsgNum() + 1);
            DbController.getInstance().getWrite().getChatContentTableDao().update(contentTable);
            return;
        }
        ChatContentTable chatContentTable = queryRowByTargetId(contentTable.getTargetId(), contentTable.getChatType());
        if (chatContentTable == null) {
            contentTable.setMsgNum(1);
            contentTable.setLoginUserId(ChatApp.getInstance().getUserId());
            DbController.getInstance().getWrite().getChatContentTableDao().insertOrReplace(contentTable);
        } else {
            contentTable.setId(chatContentTable.getId());
            contentTable.setMsgNum(chatContentTable.getMsgNum() + 1);
            DbController.getInstance().getWrite().getChatContentTableDao().update(contentTable);
        }
    }

    public static void copy(ChatContentTable oldTable, ChatContentTable table) {
        if (table == null) {
            return;
        }
        oldTable.setChatType(table.getChatType());
        oldTable.setTargetId(table.getTargetId());
        oldTable.setTargetType(table.getTargetType());
        oldTable.setTargetName(table.getTargetName());
        oldTable.setAvatarId(table.getAvatarId());
        oldTable.setTargetAvatarUrl(table.getTargetAvatarUrl());
        oldTable.setTargetMemberUserId(table.getTargetMemberUserId());
        oldTable.setMsgNum(oldTable.getMsgNum() + 1);
        oldTable.setUpdateTime(table.getUpdateTime());
        oldTable.setLastMsg(table.getLastMsg());
        oldTable.setLastMsgType(table.getLastMsgType());
        oldTable.setIsSnapchat(table.getIsSnapchat());
        oldTable.setIsRead(table.getIsRead());
        oldTable.setReceiveFrom(table.getReceiveFrom());
        oldTable.setAtelIds(table.getAtelIds());
        if (oldTable.getIsTOP() == 1) {
            oldTable.setUpdateTopTime(table.getUpdateTime());
        } else {
            oldTable.setUpdateTopTime(table.getUpdateTopTime());
        }

    }

    public static void insertNotUpdateNumber(ChatContentTable contentTable) {
        contentTable.setUpdateTime(System.currentTimeMillis());
        if (contentTable.getId() != null) {
            contentTable.setIsRead(1);
            contentTable.setMsgNum(contentTable.getMsgNum() + 1);
            DbController.getInstance().getWrite().getChatContentTableDao().update(contentTable);
            return;
        }
        ChatContentTable chatContentTable = queryRowByTargetId(contentTable.getTargetId(), contentTable.getChatType());
        if (chatContentTable == null) {
            contentTable.setIsRead(0);
            contentTable.setMsgNum(1);
            contentTable.setLoginUserId(ChatApp.getInstance().getUserId());
            DbController.getInstance().getWrite().getChatContentTableDao().insertOrReplace(contentTable);
        } else {
            contentTable.setId(chatContentTable.getId());
            contentTable.setIsRead(1);
            contentTable.setMsgNum(chatContentTable.getMsgNum() + 1);
            DbController.getInstance().getWrite().getChatContentTableDao().update(contentTable);
        }
    }

    public static void deleteById(String targetId, int chatType) {
        ChatContentTable u = queryChatContentByUserId(targetId, chatType);
        if (u != null) {
            DbController.getInstance().getWrite().getChatContentTableDao().delete(u);
        }
    }

    public static void update(ChatContentTable contentTable) {
        if (contentTable.getId() != null) {
            contentTable.setIsRead(1);
            DbController.getInstance().getWrite().getChatContentTableDao().update(contentTable);
        }
    }

    public static void delete(ChatContentTable contentTable) {
        if (contentTable != null) {
            DbController.getInstance().getWrite().getChatContentTableDao().delete(contentTable);
        }
    }

    public static void updateSumById(ChatContentTable item) {
        try {
            if (item == null) {
                return;
            }
            item.setIsRead(1);
            item.setMsgNum(0);
            DbController.getInstance().getWrite().update(item);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void updateSumById(String targetId, int chatType) {
        try {
            ChatContentTable item = ChatContentTable.queryRowByTargetId(targetId, chatType);
            if (item == null) {
                return;
            }
            item.setIsRead(1);
            item.setMsgNum(0);
            DbController.getInstance().getWrite().getChatContentTableDao().update(item);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static ChatContentTable updateLastMsgById(String targetId, String targetName, boolean isStartReadFinish, int msgType, String text, long time, int chatType, boolean taskDestory, int receiveFrom, String alias) {
        try {
            if (TextUtils.isEmpty(targetId) || taskDestory) {
                return null;
            }
            ChatContentTable u = queryChatContentByUserId(targetId, chatType);
            if (u != null) {
                u.setLastMsg(text);
                u.setLastMsgType(msgType);
                if (time != 0L) {
                    if (u.getIsTOP() == 1) {
                        u.setUpdateTopTime(time);
                    }
                    u.setUpdateTime(time);
                }

                u.setIsRead(1);
                u.setMsgNum(0);
                u.setReceiveFrom(receiveFrom);
                u.setIsSnapchat(isStartReadFinish ? 1 : 0);
                if (Canstants.GROUP_CHAT == chatType) {
                    try {
                        GroupTable g = GroupTable.queryRowByGroupId(targetId);
                        if (g != null && !TextUtils.isEmpty(g.getGroupAvatar())) {
                            u.setTargetMemberUserId(g.getGroupId());
                            u.setTargetAvatarUrl(g.getGroupAvatar());
                        } else {
                            String[] v = GroupMemberTable.getAvatarEntityLoc(targetId);
                            if (v != null) {
                                u.setTargetMemberUserId(v[0]);
                                u.setTargetAvatarUrl(v[1]);
                                u.setTargetAvatarPath(v[2]);
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    try {
                        FriendTable table = FriendTable.getTableByFriendUserId(targetId);
                        if (table != null) {
                            u.setTargetAvatarUrl(table.getFriendAvatar());
                            u.setTargetAvatarPath(table.getFriendAvatarPath());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    u.setAlias(alias);
                }
                DbController.getInstance().getWrite().getChatContentTableDao().update(u);
//                JLog.e("update msg" + u.toString());
                return u;
            } else {

//                if (chatType == MsgType.Text && TextUtils.isEmpty(text)) {
//                    return null;
//                }
                ChatContentTable chatTableBean = new ChatContentTable();
                if (Canstants.GROUP_CHAT == chatType) {
                    chatTableBean.setChatType(Canstants.GROUP_CHAT);
                    try {
                        GroupTable g = GroupTable.queryRowByGroupId(targetId);
                        if (g != null && !TextUtils.isEmpty(g.getGroupAvatar())) {
                            chatTableBean.setTargetMemberUserId(g.getGroupId());
                            chatTableBean.setTargetAvatarUrl(g.getGroupAvatar());
                        } else {
                            String[] v = GroupMemberTable.getAvatarEntityLoc(targetId);
                            if (v != null) {
                                chatTableBean.setTargetMemberUserId(v[0]);
                                chatTableBean.setTargetAvatarUrl(v[1]);
                                chatTableBean.setTargetAvatarPath(v[2]);
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    chatTableBean.setChatType(Canstants.SINGLE_CHAT);
                    chatTableBean.setAlias(alias);
                    try {
                        FriendTable table = FriendTable.getTableByFriendUserId(targetId);
                        if (table != null) {
                            chatTableBean.setTargetAvatarUrl(table.getFriendAvatar());
                            chatTableBean.setTargetAvatarPath(table.getFriendAvatarPath());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                chatTableBean.setReceiveFrom(receiveFrom);
                chatTableBean.setTargetId(targetId);
                chatTableBean.setTargetName(targetName);
                chatTableBean.setTargetType(IMSUtils.userTypeAnalysis(targetId));
                chatTableBean.setLastMsgType(msgType);
                chatTableBean.setLastMsg(text);
                chatTableBean.setIsSnapchat(isStartReadFinish ? 1 : 0);
                chatTableBean.setIsRead(1);
                chatTableBean.setMsgNum(0);
                chatTableBean.setUpdateTime(System.currentTimeMillis());
                ChatContentTable.insert(chatTableBean);
//                ChatContentTable.insertNotUpdateNumber(chatTableBean);
                return chatTableBean;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static ChatContentTable updateLastMsgByIdNotInsert(String targetId, String targetName, boolean isStartReadFinish, int msgType, String text, long time, int chatType, boolean taskDestory, int receiveFrom, String alias) {
        if (TextUtils.isEmpty(targetId) || taskDestory) {
            return null;
        }
        ChatContentTable u = queryChatContentByUserId(targetId, chatType);
        if (u != null) {
            u.setLastMsg(text);
            u.setLastMsgType(msgType);
            if (time > 0)
                u.setUpdateTime(time);
            u.setIsRead(1);
            u.setMsgNum(0);
            u.setReceiveFrom(receiveFrom);
            u.setIsSnapchat(isStartReadFinish ? 1 : 0);
            if (Canstants.GROUP_CHAT == chatType) {
                try {
                    GroupTable g = GroupTable.queryRowByGroupId(targetId);
                    if (g != null && !TextUtils.isEmpty(g.getGroupAvatar())) {
                        u.setTargetMemberUserId(g.getGroupId());
                        u.setTargetAvatarUrl(g.getGroupAvatar());
                    } else {
                        String[] v = GroupMemberTable.getAvatarEntityLoc(targetId);
                        if (v != null) {
                            u.setTargetMemberUserId(v[0]);
                            u.setTargetAvatarUrl(v[1]);
                            u.setTargetAvatarPath(v[2]);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                try {
                    FriendTable table = FriendTable.getTableByFriendUserId(targetId);
                    if (table != null) {
                        u.setTargetAvatarUrl(table.getFriendAvatar());
                        u.setTargetAvatarPath(table.getFriendAvatarPath());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                u.setAlias(alias);
            }
            DbController.getInstance().getWrite().getChatContentTableDao().update(u);
            return u;
        }
        return null;
    }

    public static ChatContentTable queryChatContentByUserId(String targetId, int chatType) {
        return DbController.getInstance().getRead()
                .getChatContentTableDao().queryBuilder().where(ChatContentTableDao.Properties.TargetId.eq(targetId),
                        ChatContentTableDao.Properties.ChatType.eq(chatType),
                        ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId())).unique();
    }

    public static List<ChatContentTable> queryChatContent(String targetId, int chatType) {
        return DbController.getInstance().getRead()
                .getChatContentTableDao().queryBuilder().where(ChatContentTableDao.Properties.TargetId.eq(targetId),
                        ChatContentTableDao.Properties.ChatType.eq(chatType),
                        ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId())).list();
    }

    /**
     * @return
     */
    public static List<ChatContentTable> queryList() {
        try {
//            .orderDesc(ChatContentTableDao.Properties.UpdateTime)
            return DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId()))
                    .list();
        } catch (Exception e) {
            return new ArrayList<>();
        }

    }

    public static List<ChatContentTable> querySortList() {
        try {
            return DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId()))
                    .orderDesc(ChatContentTableDao.Properties.IsTOP)
                    .orderDesc(ChatContentTableDao.Properties.UpdateTime)
                    .list();
        } catch (Exception e) {
            return new ArrayList<>();
        }

    }

    /**
     * @return 置顶
     */
    public static List<ChatContentTable> queryTopSortList() {
        try {
            return DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.IsTOP.eq(1),
                            ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId()))
                    .orderDesc(ChatContentTableDao.Properties.UpdateTopTime)
                    .list();
        } catch (Exception e) {
            return new ArrayList<>();
        }

    }

    public static long queryTopSortListCount() {
        try {
            return DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.IsTOP.eq(1),
                            ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId()))
                    .orderDesc(ChatContentTableDao.Properties.UpdateTopTime)
                    .count();
        } catch (Exception e) {
            return 0;
        }

    }

    public static boolean queryTopgt(long time) {
        try {
            return DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.IsTOP.eq(1),
                            ChatContentTableDao.Properties.UpdateTopTime.gt(time),
                            ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId())).count() == 0L;

        } catch (Exception e) {
            return false;
        }

    }

    public static boolean queryNormalgt(long time) {
        try {
            long count = DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.IsTOP.eq(0),
                            ChatContentTableDao.Properties.UpdateTime.gt(time),
                            ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId())).count();
            return count == 0L;
        } catch (Exception e) {
            return false;
        }

    }

    public static long queryNormalgtCount(long time) {
        try {
            return DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.IsTOP.eq(0),
                            ChatContentTableDao.Properties.UpdateTime.gt(time),
                            ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId())).count();

        } catch (Exception e) {
            return 0L;
        }

    }

    /**
     * @return 非置顶
     */
    public static List<ChatContentTable> queryNormalSortList() {
        try {
            return DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.IsTOP.eq(0),
                            ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId()))
                    .orderDesc(ChatContentTableDao.Properties.UpdateTime)
                    .list();
        } catch (Exception e) {
            return new ArrayList<>();
        }

    }

    public static List<ChatContentTable> query() {
        List<ChatContentTable> list = new ArrayList<>();
        List<ChatContentTable> listTop = queryTopSortList();
        List<ChatContentTable> listNormal = queryNormalSortList();
        if (listTop != null && !listTop.isEmpty()) {
            list.addAll(listTop);
        }
        if (listNormal != null && !listNormal.isEmpty()) {
            list.addAll(listNormal);
        }
        return list;
    }

    public static List<ChatContentTable> queryUnReadList() {
        try {
            return DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId())).list();
        } catch (Exception e) {
            return new ArrayList<>();
        }

    }

    public static boolean isExistTableByTargetId(String targetId) {
        try {
            List<ChatContentTable> b = DbController.getInstance().getRead()
                    .getChatContentTableDao().queryBuilder()
                    .where(ChatContentTableDao.Properties.TargetId.eq(targetId), ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId())).list();
            return b != null && !b.isEmpty();
        } catch (Exception e) {
            return false;
        }

    }

    /**
     * 获取未读消息数量
     */
    public static long getUnReadChatSum(List<ChatContentTable> list) {
        long sum = 0;
        for (ChatContentTable table : list) {
            long count = ChatTableBean.queryUnreadChatCount(table.getChatType(), table.getTargetId());
//            if (table.getIsRead() == 0 ) {
            sum += count;
//            }
        }
        return sum;
    }

    public static ChatContentTable queryRowByTargetIdNotNull(String targetId, int chatType) {
        ChatContentTable u = DbController.getInstance().getRead()
                .getChatContentTableDao().queryBuilder()
                .where(ChatContentTableDao.Properties.TargetId.eq(targetId), ChatContentTableDao.Properties.ChatType.eq(chatType),
                        ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId())).unique();
        return u == null ? new ChatContentTable() : u;
    }

    public static ChatContentTable queryRowByTargetId(String targetId, int chatType) {
        return DbController.getInstance().getRead()
                .getChatContentTableDao().queryBuilder()
                .where(ChatContentTableDao.Properties.TargetId.eq(targetId), ChatContentTableDao.Properties.ChatType.eq(chatType),
                        ChatContentTableDao.Properties.LoginUserId.eq(ChatApp.getInstance().getUserId())).unique();
    }

    public static ChatContentTable queryRowById(Long id) {
        return DbController.getInstance().getRead()
                .getChatContentTableDao().loadByRowId(id);
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public int getChatType() {
        return this.chatType;
    }

    public void setChatType(int chatType) {
        this.chatType = chatType;
    }

    public String getTargetId() {
        return this.targetId;
    }

    public void setTargetId(String targetId) {
        this.targetId = targetId;
    }

    public String getTargetType() {
        return this.targetType;
    }

    public void setTargetType(String targetType) {
        this.targetType = targetType;
    }

    public String getTargetName() {
        return this.targetName;
    }

    public void setTargetName(String targetName) {
        this.targetName = targetName;
    }

    public String getTargetAvatarUrl() {
        return this.targetAvatarUrl;
    }

    public void setTargetAvatarUrl(String targetAvatarUrl) {
        this.targetAvatarUrl = targetAvatarUrl;
    }

    public String getAvatarId() {
        return this.avatarId;
    }

    public void setAvatarId(String avatarId) {
        this.avatarId = avatarId;
    }

    public int getMsgNum() {
        return this.msgNum;
    }

    public void setMsgNum(int msgNum) {
        this.msgNum = msgNum;
    }

    public String getLoginUserId() {
        return this.loginUserId;
    }

    public void setLoginUserId(String loginUserId) {
        this.loginUserId = loginUserId;
    }


    public String getTargetMemberUserId() {
        return this.targetMemberUserId;
    }

    public void setTargetMemberUserId(String targetMemberUserId) {
        this.targetMemberUserId = targetMemberUserId;
    }

    public long getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(long updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public int compareTo(ChatContentTable o) {
        if (o.getUpdateTime() > getUpdateTime()) {
            return 1;
        }
        if (o.getUpdateTime() < getUpdateTime()) {
            return -1;
        }
        return 0;
    }

    public String getLastMsg() {
        return this.lastMsg;
    }

    public void setLastMsg(String lastMsg) {
        this.lastMsg = lastMsg;
    }

    public int getLastMsgType() {
        return this.lastMsgType;
    }

    public void setLastMsgType(int lastMsgType) {
        this.lastMsgType = lastMsgType;
    }

    public int getIsSnapchat() {
        return this.isSnapchat;
    }

    public void setIsSnapchat(int isSnapchat) {
        this.isSnapchat = isSnapchat;
    }

//    public static class MemberConverter extends DbConverterList<GroupMemberTable> {
//    }

    @Override
    public String toString() {
        return "ChatContentTable{" +
                "id=" + id +
                ", chatType=" + chatType +
                ", targetId='" + targetId + '\'' +
                ", targetType='" + targetType + '\'' +
                ", targetName='" + targetName + '\'' +
                ", avatarId='" + avatarId + '\'' +
                ", targetAvatarUrl='" + targetAvatarUrl + '\'' +
                ", targetMemberUserId='" + targetMemberUserId + '\'' +
                ", msgNum=" + msgNum +
                ", loginUserId='" + loginUserId + '\'' +
                ", updateTime=" + updateTime +
                ", lastMsg='" + lastMsg + '\'' +
                ", lastMsgType=" + lastMsgType +
                ", isSnapchat=" + isSnapchat +
                '}';
    }

    public int getIsTOP() {
        return this.isTOP;
    }

    public void setIsTOP(int isTOP) {
        this.isTOP = isTOP;
    }

    public int getIsRead() {
        return this.isRead;
    }

    public void setIsRead(int isRead) {
        this.isRead = isRead;
    }

    public String getTargetAvatarPath() {
        return this.targetAvatarPath;
    }

    public void setTargetAvatarPath(String targetAvatarPath) {
        this.targetAvatarPath = targetAvatarPath;
    }

    public int getReceiveFrom() {
        return receiveFrom;
    }

    public void setReceiveFrom(int receiveFrom) {
        this.receiveFrom = receiveFrom;
    }

    public String getAlias() {
        return this.alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getAtelIds() {
        return this.atelIds;
    }

    public void setAtelIds(String atelIds) {
        this.atelIds = atelIds;
    }

    public long getUpdateTopTime() {
        return this.updateTopTime;
    }

    public void setUpdateTopTime(long updateTopTime) {
        this.updateTopTime = updateTopTime;
    }


}
